package com.woniu.presell.controller;

import com.woniu.common.util.Result;
import com.woniu.common.util.ResultVO;
import com.woniu.presell.VO.RoomVO;
import com.woniu.presell.entity.Room;
import com.woniu.presell.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @program: house-after
 * @description:
 * @author: qqq
 * @create: 2022-12-07 16:01
 **/
@RestController
@RequestMapping("/Rooms")
public class RoomController {
    @Autowired
    private RoomService roomService;
    @GetMapping("/queryAll/{id}")
    public Result queryAllRoom(@PathVariable("id") Long id){
        List<RoomVO> roomList = roomService.selectByFloorId(id);
        if(roomList.size()>0){
           return Result.ok().data("roomList",roomList);
        }else{
           return Result.error();
        }
    }
    @GetMapping("/queryById/{id}")
    public Result queryById(@PathVariable("id") Long id){
        Room room = roomService.selectByRoomId(id);
        if(room!=null){
            return Result.ok().data("room",room);
        }else{
            return Result.error();
        }
    }
}
